<?php
declare (strict_types = 1);

namespace app\qingadmin\middleware;

class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    
    public function handle($request, \Closure $next)
    {
        //
        //echo '我是应用中间件，我在这里处理登录逻辑';
        if(empty(session('adminSessionData')) && !preg_match('/login/',$request->pathinfo())){
            return redirect((string) url('login/index'));
        }
        return $next($request);
    }
    
    /** 
    public function handle($request, \Closure $next)
    {
        $response=$next($response);
        echo '我是应用中间件，我在这里处理登录逻辑'
        return response;
    }
    */
}
